using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class JcMap : EntityTypeConfiguration<Jc>
    {
        public JcMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.DESC)
                .HasMaxLength(40);

            this.Property(t => t.TYPE)
                .HasMaxLength(2);

            this.Property(t => t.CSTCTR)
                .HasMaxLength(9);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Jc");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.JOBID).HasColumnName("JOBID");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.AMT).HasColumnName("AMT");
            this.Property(t => t.CSTCTR).HasColumnName("CSTCTR");
            this.Property(t => t.AMTDOL).HasColumnName("AMTDOL");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.Job)
                .WithMany(t => t.Jcs)
                .HasForeignKey(d => d.JOBID);

        }
    }
}
